﻿<Window x:Class="SoftTeach.View.Stundenentwürfe.SearchStundenentwurfDialog"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:softTeach="clr-namespace:SoftTeach"
        xmlns:controls="clr-namespace:SoftTeach.Resources.Controls"
        xmlns:pushBinding="clr-namespace:SoftTeach.ViewModel.Helper.PushBinding"
        Title="Stundenentwurf ..." 
        Icon="/SoftTeach;component/Images/Stundenentwurf32.png"
        WindowState="Maximized"
        Height="600" 
        Width="900">
  <Window.Resources>
    <CollectionViewSource Source="{Binding Path=FilteredAndSortedStundenentwürfe}" x:Key="GroupedStundenentwürfe">
      <CollectionViewSource.GroupDescriptions>
        <PropertyGroupDescription PropertyName="Jahresplan.JahresplanJahrtyp.JahrtypJahr"/>
        <PropertyGroupDescription PropertyName="Klasse"/>
      </CollectionViewSource.GroupDescriptions>
    </CollectionViewSource>
  </Window.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="*"/>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <controls:SmallDialogHeader Grid.Row="0" Title="Stundenentwurf auswählen ..."
                                      Icon="/SoftTeach;component/Images/Stundenentwurf32.png"/>
    <Grid Background="{StaticResource DefaultOfficeBackgroundBrush}" Grid.Row="1" >
      <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="Auto"/>
          <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <ToolBarPanel Grid.Row="0">
          <ToolBar>
            <Label Padding="0" Margin="3"  VerticalContentAlignment="Center">Filtern nach: Fach</Label>
            <ComboBox MinWidth="100" ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Fächer}"
                              SelectedValue="{Binding Path=FachFilter}" 
                              SelectedValuePath="." 
                              DisplayMemberPath="FachBezeichnung"/>
            <Label Padding="0" Margin="3" VerticalContentAlignment="Center">und Jahrgangsstufe</Label>
            <ComboBox MinWidth="100" ItemsSource="{Binding Source={x:Static softTeach:App.MainViewModel}, Path=Jahrgangsstufen}"
                              SelectedValue="{Binding Path=JahrgangsstufeFilter}"
                              SelectedValuePath="." 
                              DisplayMemberPath="JahrgangsstufeBezeichnung"/>
            <Label Padding="0" Margin="3" VerticalContentAlignment="Center">und Modul</Label>
            <ComboBox MinWidth="100" ItemsSource="{Binding Path=FilteredModule}"
                              SelectedValue="{Binding Path=ModulFilter}"
                              SelectedValuePath="." 
                              DisplayMemberPath="ModulBezeichnung"/>
            <Separator Margin="10,0,10,0" ></Separator>
            <Button Width="Auto" Name="RemoveFilterButton" Command="{Binding Path=RemoveFilterCommand}">
              Filter zurücksetzen.
            </Button>
          </ToolBar>
        </ToolBarPanel>
        <!--<DataGrid Grid.Row="1" SelectedItem="{Binding Path=CurrentStundenentwurf, Mode=TwoWay}" ItemsSource="{Binding Path=FilteredStundenentwürfe}" AutoGenerateColumns="False" IsReadOnly="True">
          <DataGrid.Columns>
            <DataGridTextColumn Header="Modul" Binding="{Binding Path=StundenentwurfModul.ModulBezeichnung}" Width="100" />
            <DataGridTextColumn Header="Stundenthema" Binding="{Binding Path=StundenentwurfStundenthema}"/>
            <DataGridTextColumn Header="Phasen" Binding="{Binding Path=StundenentwurfPhasenKurzform}" Width="*"/>
            <DataGridTextColumn Header="Stundenzahl" Binding="{Binding Path=StundenentwurfStundenzahl}" />
          </DataGrid.Columns>
        </DataGrid>-->
        <!--ItemContainerStyle="{StaticResource NoBorderListBoxItemStyle}"-->

        <ListBox Grid.Row="1" Background="Transparent" 
                 ItemsSource="{Binding Source={StaticResource GroupedStundenentwürfe}}" 
                 ItemTemplate="{StaticResource StundenentwurfTile}"
                 BorderThickness="0"
                 SelectionMode="Extended"
                 SelectedItem="{Binding CurrentStundenentwurfEintrag, Mode=TwoWay}">
          <pushBinding:PushBindingManager.PushBindings>
            <pushBinding:PushBinding TargetProperty="SelectedItems" Path="SelectedStundenentwurfEinträge"/>
          </pushBinding:PushBindingManager.PushBindings>
          <ListBox.InputBindings>
            <KeyBinding Key="Delete" Command="{Binding Path=DeleteStundenentwurfEintragCommand}"/>
          </ListBox.InputBindings>
          <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
              <StackPanel/>
            </ItemsPanelTemplate>
          </ListBox.ItemsPanel>
          <ListBox.GroupStyle>
            <GroupStyle ContainerStyle="{StaticResource JahrtypenHeaderStyle}">
              <GroupStyle.Panel>
                <ItemsPanelTemplate>
                  <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
              </GroupStyle.Panel>
            </GroupStyle>
            <GroupStyle ContainerStyle="{StaticResource JahrtypenHeaderStyle}">
              <GroupStyle.Panel>
                <ItemsPanelTemplate>
                  <StackPanel Orientation="Horizontal"/>
                </ItemsPanelTemplate>
              </GroupStyle.Panel>
            </GroupStyle>
          </ListBox.GroupStyle>
          <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
              <Setter Property="Padding" Value="0"/>
              <Setter Property="Opacity" Value="0.7" />
              <Setter Property="Template">
                <Setter.Value>
                  <ControlTemplate TargetType="ListBoxItem">
                    <Border x:Name="Border" Padding="0" SnapsToDevicePixels="true">
                      <ContentPresenter />
                    </Border>
                  </ControlTemplate>
                </Setter.Value>
              </Setter>
              <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                  <Trigger.Setters>
                    <Setter Property="Opacity" Value="1.0" />
                  </Trigger.Setters>
                </Trigger>
              </Style.Triggers>
            </Style>
          </ListBox.ItemContainerStyle>
        </ListBox>

      </Grid>
    </Grid>
    <Grid Background="{StaticResource DefaultButtonsBackgroundBrush}" Grid.Row="2">
      <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="10">
        <Button Width="150" IsDefault="True" Click="KopieClick" TabIndex="2">Als Kopie übernehmen</Button>
        <Label></Label>
        <Button Width="170" IsDefault="False" Click="LinkClick" TabIndex="2">Als Verknüpfung übernehmen</Button>
        <Label></Label>
        <Button Width="100" IsCancel="True" Click="CancelClick">Abbrechen</Button>
      </StackPanel>
    </Grid>
  </Grid>
</Window>
